//
//  ClassifyButton.m
//  KiklinkApp
//
//  Created by LJC on 14-9-11.
//  Copyright (c) 2014年 Kiklink. All rights reserved.
//

#import "ClassifyButton.h"

#import "UIColor+hex.h"

@implementation ClassifyButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)awakeFromNib
{
    self.backgroundColor = [UIColor colorWithHexString:AppColor_sliderUnselected andAlpha:0.5];
    [self.layer setMasksToBounds:YES];
    [self.layer setCornerRadius:14];
    [self.layer setBorderWidth:0];
    [self.layer setBorderColor:[UIColor colorWithHexString:AppColor_Main].CGColor];
    [self setTitleColor:[UIColor colorWithHexString:AppColor_Text] forState:UIControlStateNormal];
    self.selectType = @"selected";
}

- (void)changeStyle
{
    if ([self.selectType isEqualToString:@"selected"]) {
        self.selectType = @"UnSelected";
        [self.layer setBorderWidth:0];
        self.backgroundColor = [UIColor colorWithHexString:AppColor_sliderUnselected andAlpha:0.5];
        [self setTitleColor:[UIColor colorWithHexString:AppColor_Text] forState:UIControlStateNormal];
    } else{
        self.selectType = @"selected";
        [self.layer setBorderWidth:1.5];
        self.backgroundColor = [UIColor whiteColor];
        [self setTitleColor:[UIColor colorWithHexString:AppColor_Main] forState:UIControlStateNormal];
    }
}

+ (ClassifyButton *)buttonWithPosition:(CGPoint)point andTitle:(NSString *)title
{
    ClassifyButton *classifyBtn = [ClassifyButton buttonWithType:UIButtonTypeCustom];
    classifyBtn.frame = CGRectMake(point.x, point.y, 90, 30);
    classifyBtn.backgroundColor = [UIColor colorWithHexString:AppColor_sliderUnselected];
    [classifyBtn.layer setMasksToBounds:YES];
    [classifyBtn.layer setCornerRadius:14];
    [classifyBtn.layer setBorderWidth:0];
    [classifyBtn.layer setBorderColor:[UIColor colorWithHexString:AppColor_Main].CGColor];
    [classifyBtn setTitle:title forState:UIControlStateNormal];
    classifyBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [classifyBtn setTitleColor:[UIColor colorWithHexString:AppColor_Text] forState:UIControlStateNormal];
    classifyBtn.selectType = @"selected";
    return classifyBtn;
}

@end
